using System;
using System.Collections.Generic;
using MongoDB.Bson.Serialization;

namespace MongoScienceDAL.Core
{
    public class ScienceSeralisationProvider : IBsonSerializationProvider
    {
        private readonly IDictionary<Type, IBsonSerializer> _serializers;

        public ScienceSeralisationProvider()
        {
            _serializers = new Dictionary<Type, IBsonSerializer>();
        }

        public void Add(Type type, IBsonSerializer serializer)
        {
            _serializers.Add(type, serializer);
        }

        public void ClearAll()
        {
            _serializers.Clear();   
        }

        public IBsonSerializer GetSerializer(Type type)
        {
            return _serializers.ContainsKey(type) ? _serializers[type] : null;
        }
    }
}